<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>用户服务协议</title>
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/swiper.min.css">
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/mui.css?v=1">
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/mobileSelect.css" />
		<link rel="stylesheet" href="__API__/lib/css/style.css">
		<script type="text/javascript" src="__API__/lib/js/jquery-1.11.0.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/mui.js"></script>
		<script src="__API__/lib/js/mobileSelect.js" type="text/javascript" charset="utf-8"></script>
		<script src="__API__/lib/js/city.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="__API__/lib/js/swiper.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/vue.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/common.js"></script>
		<script type="text/javascript" src="__API__/lib/js/index.js"></script>
	<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script></head>

	<body>
		<div class="class_page bg_color" id="app">

			<div class="shopinfo_box" id="info">

				<div class="info" v-html="data"></div>
			</div>
			<div class="fb"></div>


		</div>
		<script>

			var app = null;
			app = new Vue({
				el: '#app',
				data: {
					data: {

					},
					isCartShow: false,
					level_id:0,
					scrollTop: 0,
					goodsNum: 1,
					type:0
				},
				mounted() {
					window.addEventListener('scroll', this.handleScroll) // 监听页面滚动
				},		created: function() {
					let that=this;

					var id = "{:input('id')}";
					common.ajax("{:url('OnePage/json')}",{token:localStorage.getItem('token'),id:10} , function(res){
						that.data =res.data
					})

				},
				methods: {


					// 获取页面滚动距离
					handleScroll() {
						let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body
							.scrollTop;
						this.scrollTop = scrollTop;
					},
					//返回顶部
					backTop() {
						window.scrollTo({
							top: 0,
							behavior: "smooth"
						});
					},
					goDetail(url) {
						common.openUrl(url)
					},
					//开启购物车
					addcart(type) {
						this.isCartShow = true;
						this.type=type
						console.log(type)
					},
					//关闭购物车
					closeCart() {
						this.isCartShow = false;
					},
					//数量
					carts(type) {
						if (type == 'sub') {
							if (this.goodsNum > 1) {
								this.goodsNum--;
							}
						}
						if (type == 'add') {
							this.goodsNum++;
						}
					},
					//加入购物车
					addCart() {

						common.ajax("{:url('Cart/create')}",{type:this.type,token:localStorage.getItem('token'),goods_id:this.data.id,number:this.goodsNum} , function(res){
							common.showToast(res.msg);

							if(res.code==201){
								setTimeout(function() {
									common.openUrl("{:url('order_submit')}?cart_id="+res.cart_id+'&type=buy');
								}, 1000)

							}

						})

						this.isCartShow = false;
						//关闭弹窗
					},
					//立即购买
					nowBuy() {

						//跳转提交订单页
						common.openUrl('order_submit.html');
						//关闭弹窗
						this.closeCart();
					}
				}
			});
		</script>
	</body>

</html>
